home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / Sound.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  25KB  |  722 lines

  1. /*
  2.      File:        Sound.h
  3.  
  4.      Contains:    Sound Manager Interfaces.
  5.  
  6.      Version:    Technology:    Sound Manager 3.1
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __SOUND__
  19. #define __SOUND__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __COMPONENTS__
  25. #include <Components.h>
  26. #endif
  27. #ifndef __MIXEDMODE__
  28. #include <MixedMode.h>
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT_SUPPORTED
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_ALIGN_SUPPORTED
  40. #pragma options align=mac68k
  41. #endif
  42.  
  43. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  44. /*
  45.                         * * *  N O T E  * * *
  46.  
  47.     This file has been updated to include Sound Manager 3.2 interfaces.
  48.  
  49.     Some of the Sound Manager 3.0 interfaces were not put into the InterfaceLib
  50.     that originally shipped with the PowerMacs. These missing functions and the
  51.     new 3.2 interfaces have been released in the SoundLib library for PowerPC
  52.     developers to link with. The runtime library for these functions are
  53.     installed by Sound Manager 3.2. The following functions are found in SoundLib.
  54.  
  55.         GetCompressionInfo(), GetSoundPreference(), SetSoundPreference(),
  56.         UnsignedFixedMulDiv(), SndGetInfo(), SndSetInfo(), GetSoundOutputInfo(),
  57.         SetSoundOutputInfo(), GetCompressionName(), SoundConverterOpen(),
  58.         SoundConverterClose(), SoundConverterGetBufferSizes(), SoundConverterBeginConversion(),
  59.         SoundConverterConvertBuffer(), SoundConverterEndConversion()
  60. */
  61. /*
  62.     Interfaces for Sound Driver, !!! OBSOLETE and NOT SUPPORTED !!!
  63.  
  64.     These items are no longer defined, but appear here so that someone
  65.     searching the interfaces might find them. If you are using one of these
  66.     items, you must change your code to support the Sound Manager.
  67.  
  68.         swMode, ftMode, ffMode
  69.         FreeWave, FFSynthRec, Tone, SWSynthRec, Wave, FTSoundRec
  70.         SndCompletionProcPtr
  71.         StartSound, StopSound, SoundDone
  72. */
  73.  
  74.  
  75.  
  76. enum {
  77.     soundListRsrc                = 'snd ',                        /*Resource type used by Sound Manager*/
  78.     rate44khz                    = 0xAC440000,                    /*44100.00000 in fixed-point*/
  79.     rate22050hz                    = 0x56220000,                    /*22050.00000 in fixed-point*/
  80.     rate22khz                    = 0x56EE8BA3,                    /*22254.54545 in fixed-point*/
  81.     rate11khz                    = 0x2B7745D1,                    /*11127.27273 in fixed-point*/
  82.     rate11025hz                    = 0x2B110000,                    /*11025.00000 in fixed-point*/
  83.                                                                 /*synthesizer numbers for SndNewChannel*/
  84.     squareWaveSynth                = 1,                            /*square wave synthesizer*/
  85.     waveTableSynth                = 3,                            /*wave table synthesizer*/
  86.     sampledSynth                = 5,                            /*sampled sound synthesizer*/
  87.                                                                 /*old Sound Manager MACE synthesizer numbers*/
  88.     MACE3snthID                    = 11,
  89.     MACE6snthID                    = 13,
  90.     kMiddleC                    = 60,                            /*MIDI note value for middle C*/
  91.     kSimpleBeepID                = 1,                            /*reserved resource ID for Simple Beep*/
  92.     kFullVolume                    = 0x0100,                        /*1.0, setting for full hardware output volume*/
  93.     kNoVolume                    = 0,                            /*setting for no sound volume*/
  94.                                                                 /*command numbers for SndDoCommand and SndDoImmediate*/
  95.     nullCmd                        = 0,
  96.     initCmd                        = 1,
  97.     freeCmd                        = 2,
  98.     quietCmd                    = 3,
  99.     flushCmd                    = 4,
  100.     reInitCmd                    = 5,
  101.     waitCmd                        = 10,
  102.     pauseCmd                    = 11,
  103.     resumeCmd                    = 12,
  104.     callBackCmd                    = 13
  105. };
  106.  
  107.  
  108. enum {
  109.     syncCmd                        = 14,
  110.     availableCmd                = 24,
  111.     versionCmd                    = 25,
  112.     totalLoadCmd                = 26,
  113.     loadCmd                        = 27,
  114.     freqDurationCmd                = 40,
  115.     restCmd                        = 41,
  116.     freqCmd                        = 42,
  117.     ampCmd                        = 43,
  118.     timbreCmd                    = 44,
  119.     getAmpCmd                    = 45,
  120.     volumeCmd                    = 46,                            /*sound manager 3.0 or later only*/
  121.     getVolumeCmd                = 47,                            /*sound manager 3.0 or later only*/
  122.     waveTableCmd                = 60,
  123.     phaseCmd                    = 61
  124. };
  125.  
  126.  
  127. enum {
  128.     soundCmd                    = 80,
  129.     bufferCmd                    = 81,
  130.     rateCmd                        = 82,
  131.     continueCmd                    = 83,
  132.     doubleBufferCmd                = 84,
  133.     getRateCmd                    = 85,
  134.     rateMultiplierCmd            = 86,
  135.     getRateMultiplierCmd        = 87,
  136.     sizeCmd                        = 90,                            /*obsolete command*/
  137.     convertCmd                    = 91,                            /*obsolete MACE command*/
  138.     stdQLength                    = 128,
  139.     dataOffsetFlag                = 0x8000
  140. };
  141.  
  142. /*channel initialization parameters*/
  143. #if OLDROUTINENAMES
  144.  
  145. enum {
  146.     waveInitChannelMask            = 0x07,
  147.     waveInitChannel0            = 0x04,                            /*wave table only, Sound Manager 2.0 and earlier*/
  148.     waveInitChannel1            = 0x05,                            /*wave table only, Sound Manager 2.0 and earlier*/
  149.     waveInitChannel2            = 0x06,                            /*wave table only, Sound Manager 2.0 and earlier*/
  150.     waveInitChannel3            = 0x07,                            /*wave table only, Sound Manager 2.0 and earlier*/
  151.     initChan0                    = waveInitChannel0,                /*obsolete spelling*/
  152.     initChan1                    = waveInitChannel1,                /*obsolete spelling*/
  153.     initChan2                    = waveInitChannel2,                /*obsolete spelling*/
  154.     initChan3                    = waveInitChannel3                /*obsolete spelling*/
  155. };
  156.  
  157. #endif
  158.  
  159. enum {
  160.     initChanLeft                = 0x0002,                        /*left stereo channel*/
  161.     initChanRight                = 0x0003,                        /*right stereo channel*/
  162.     initNoInterp                = 0x0004,                        /*no linear interpolation*/
  163.     initNoDrop                    = 0x0008,                        /*no drop-sample conversion*/
  164.     initMono                    = 0x0080,                        /*monophonic channel*/
  165.     initStereo                    = 0x00C0,                        /*stereo channel*/
  166.     initMACE3                    = 0x0300,                        /*MACE 3:1*/
  167.     initMACE6                    = 0x0400,                        /*MACE 6:1*/
  168.     initPanMask                    = 0x0003,                        /*mask for right/left pan values*/
  169.     initSRateMask                = 0x0030,                        /*mask for sample rate values*/
  170.     initStereoMask                = 0x00C0,                        /*mask for mono/stereo values*/
  171.     initCompMask                = 0xFF00,                        /*mask for compression IDs*/
  172.     kUseOptionalOutputDevice    = -1,                            /*only for Sound Manager 3.0 or later*/
  173.     notCompressed                = 0,                            /*compression ID's*/
  174.     fixedCompression            = -1,                            /*compression ID for fixed-sized compression*/
  175.     variableCompression            = -2,                            /*compression ID for variable-sized compression*/
  176.     twoToOne                    = 1,
  177.     eightToThree                = 2,
  178.     threeToOne                    = 3,
  179.     sixToOne                    = 4
  180. };
  181.  
  182.  
  183. enum {
  184.     stdSH                        = 0x00,                            /*Standard sound header encode value*/
  185.     extSH                        = 0xFF,                            /*Extended sound header encode value*/
  186.     cmpSH                        = 0xFE                            /*Compressed sound header encode value*/
  187. };
  188.  
  189.  
  190. enum {
  191.     outsideCmpSH                = 0,                            /*obsolete MACE constant*/
  192.     insideCmpSH                    = 1,                            /*obsolete MACE constant*/
  193.     aceSuccess                    = 0,                            /*obsolete MACE constant*/
  194.     aceMemFull                    = 1,                            /*obsolete MACE constant*/
  195.     aceNilBlock                    = 2,                            /*obsolete MACE constant*/
  196.     aceBadComp                    = 3,                            /*obsolete MACE constant*/
  197.     aceBadEncode                = 4,                            /*obsolete MACE constant*/
  198.     aceBadDest                    = 5,                            /*obsolete MACE constant*/
  199.     aceBadCmd                    = 6,                            /*obsolete MACE constant*/
  200.     sixToOnePacketSize            = 8,
  201.     threeToOnePacketSize        = 16,
  202.     stateBlockSize                = 64,
  203.     leftOverBlockSize            = 32,
  204.     firstSoundFormat            = 0x0001,                        /*general sound format*/
  205.     secondSoundFormat            = 0x0002,                        /*special sampled sound format (HyperCard)*/
  206.     dbBufferReady                = 0x00000001,                    /*double buffer is filled*/
  207.     dbLastBuffer                = 0x00000004,                    /*last double buffer to play*/
  208.     sysBeepDisable                = 0x0000,                        /*SysBeep() enable flags*/
  209.     sysBeepEnable                = (1 << 0),
  210.     sysBeepSynchronous            = (1 << 1),                        /*if bit set, make alert sounds synchronous*/
  211.     unitTypeNoSelection            = 0xFFFF,                        /*unitTypes for AudioSelection.unitType*/
  212.     unitTypeSeconds                = 0x0000
  213. };
  214.  
  215. #define twelfthRootTwo 1.05946309435
  216.  
  217. /*unsigned fixed-point number*/
  218. typedef unsigned long UnsignedFixed;
  219. struct SndCommand {
  220.     unsigned short                     cmd;
  221.     short                             param1;
  222.     long                             param2;
  223. };
  224. typedef struct SndCommand SndCommand;
  225.  
  226. typedef struct SndChannel SndChannel;
  227. typedef SndChannel *SndChannelPtr;
  228. typedef pascal void (*SndCallBackProcPtr)(SndChannelPtr chan, SndCommand *cmd);
  229.  
  230. #if GENERATINGCFM
  231. typedef UniversalProcPtr SndCallBackUPP;
  232. #else
  233. typedef SndCallBackProcPtr SndCallBackUPP;
  234. #endif
  235. struct SndChannel {
  236.     SndChannelPtr                     nextChan;
  237.     Ptr                             firstMod;                    /* reserved for the Sound Manager */
  238.     SndCallBackUPP                     callBack;
  239.     long                             userInfo;
  240.     long                             wait;                        /* The following is for internal Sound Manager use only.*/
  241.     SndCommand                         cmdInProgress;
  242.     short                             flags;
  243.     short                             qLength;
  244.     short                             qHead;
  245.     short                             qTail;
  246.     SndCommand                         queue[128];
  247. };
  248.  
  249. /*MACE structures*/
  250. struct StateBlock {
  251.     short                             stateVar[64];
  252. };
  253. typedef struct StateBlock StateBlock;
  254.  
  255. typedef StateBlock *StateBlockPtr;
  256. struct LeftOverBlock {
  257.     unsigned long                     count;
  258.     SInt8                             sampleArea[32];
  259. };
  260. typedef struct LeftOverBlock LeftOverBlock;
  261.  
  262. typedef LeftOverBlock *LeftOverBlockPtr;
  263. struct ModRef {
  264.     unsigned short                     modNumber;
  265.     long                             modInit;
  266. };
  267. typedef struct ModRef ModRef;
  268.  
  269. struct SndListResource {
  270.     short                             format;
  271.     short                             numModifiers;
  272.     ModRef                             modifierPart[1];
  273.     short                             numCommands;
  274.     SndCommand                         commandPart[1];
  275.     UInt8                             dataPart[1];
  276. };
  277. typedef struct SndListResource SndListResource;
  278.  
  279. typedef SndListResource *SndListPtr;
  280. typedef SndListPtr *SndListHndl;
  281. typedef SndListPtr *SndListHandle;
  282. /*HyperCard sound resource format*/
  283. struct Snd2ListResource {
  284.     short                             format;
  285.     short                             refCount;
  286.     short                             numCommands;
  287.     SndCommand                         commandPart[1];
  288.     UInt8                             dataPart[1];
  289. };
  290. typedef struct Snd2ListResource Snd2ListResource;
  291.  
  292. typedef Snd2ListResource *Snd2ListPtr;
  293. typedef Snd2ListPtr *Snd2ListHndl;
  294. typedef Snd2ListPtr *Snd2ListHandle;
  295. struct SoundHeader {
  296.     Ptr                             samplePtr;                    /*if NIL then samples are in sampleArea*/
  297.     unsigned long                     length;                        /*length of sound in bytes*/
  298.     UnsignedFixed                     sampleRate;                    /*sample rate for this sound*/
  299.     unsigned long                     loopStart;                    /*start of looping portion*/
  300.     unsigned long                     loopEnd;                    /*end of looping portion*/
  301.     UInt8                             encode;                        /*header encoding*/
  302.     UInt8                             baseFrequency;                /*baseFrequency value*/
  303.     UInt8                             sampleArea[1];                /*space for when samples follow directly*/
  304. };
  305. typedef struct SoundHeader SoundHeader;
  306.  
  307. typedef SoundHeader *SoundHeaderPtr;
  308. struct CmpSoundHeader {
  309.     Ptr                             samplePtr;                    /*if nil then samples are in sample area*/
  310.     unsigned long                     numChannels;                /*number of channels i.e. mono = 1*/
  311.     UnsignedFixed                     sampleRate;                    /*sample rate in Apples Fixed point representation*/
  312.     unsigned long                     loopStart;                    /*loopStart of sound before compression*/
  313.     unsigned long                     loopEnd;                    /*loopEnd of sound before compression*/
  314.     UInt8                             encode;                        /*data structure used , stdSH, extSH, or cmpSH*/
  315.     UInt8                             baseFrequency;                /*same meaning as regular SoundHeader*/
  316.     unsigned long                     numFrames;                    /*length in frames ( packetFrames or sampleFrames )*/
  317.     extended80                         AIFFSampleRate;                /*IEEE sample rate*/
  318.     Ptr                             markerChunk;                /*sync track*/
  319.     OSType                             format;                        /*data format type, was futureUse1*/
  320.     unsigned long                     futureUse2;                    /*reserved by Apple*/
  321.     StateBlockPtr                     stateVars;                    /*pointer to State Block*/
  322.     LeftOverBlockPtr                 leftOverSamples;            /*used to save truncated samples between compression calls*/
  323.     short                             compressionID;                /*0 means no compression, non zero means compressionID*/
  324.     unsigned short                     packetSize;                    /*number of bits in compressed sample packet*/
  325.     unsigned short                     snthID;                        /*resource ID of Sound Manager snth that contains NRT C/E*/
  326.     unsigned short                     sampleSize;                    /*number of bits in non-compressed sample*/
  327.     UInt8                             sampleArea[1];                /*space for when samples follow directly*/
  328. };
  329. typedef struct CmpSoundHeader CmpSoundHeader;
  330.  
  331. typedef CmpSoundHeader *CmpSoundHeaderPtr;
  332. struct ExtSoundHeader {
  333.     Ptr                             samplePtr;                    /*if nil then samples are in sample area*/
  334.     unsigned long                     numChannels;                /*number of channels,  ie mono = 1*/
  335.     UnsignedFixed                     sampleRate;                    /*sample rate in Apples Fixed point representation*/
  336.     unsigned long                     loopStart;                    /*same meaning as regular SoundHeader*/
  337.     unsigned long                     loopEnd;                    /*same meaning as regular SoundHeader*/
  338.     UInt8                             encode;                        /*data structure used , stdSH, extSH, or cmpSH*/
  339.     UInt8                             baseFrequency;                /*same meaning as regular SoundHeader*/
  340.     unsigned long                     numFrames;                    /*length in total number of frames*/
  341.     extended80                         AIFFSampleRate;                /*IEEE sample rate*/
  342.     Ptr                             markerChunk;                /*sync track*/
  343.     Ptr                             instrumentChunks;            /*AIFF instrument chunks*/
  344.     Ptr                             AESRecording;
  345.     unsigned short                     sampleSize;                    /*number of bits in sample*/
  346.     unsigned short                     futureUse1;                    /*reserved by Apple*/
  347.     unsigned long                     futureUse2;                    /*reserved by Apple*/
  348.     unsigned long                     futureUse3;                    /*reserved by Apple*/
  349.     unsigned long                     futureUse4;                    /*reserved by Apple*/
  350.     UInt8                             sampleArea[1];                /*space for when samples follow directly*/
  351. };
  352. typedef struct ExtSoundHeader ExtSoundHeader;
  353.  
  354. typedef ExtSoundHeader *ExtSoundHeaderPtr;
  355. struct ConversionBlock {
  356.     short                             destination;
  357.     short                             unused;
  358.     CmpSoundHeaderPtr                 inputPtr;
  359.     CmpSoundHeaderPtr                 outputPtr;
  360. };
  361. typedef struct ConversionBlock ConversionBlock;
  362.  
  363. typedef ConversionBlock *ConversionBlockPtr;
  364. struct SMStatus {
  365.     short                             smMaxCPULoad;
  366.     short                             smNumChannels;
  367.     short                             smCurCPULoad;
  368. };
  369. typedef struct SMStatus SMStatus;
  370.  
  371. typedef SMStatus *SMStatusPtr;
  372. struct SCStatus {
  373.     UnsignedFixed                     scStartTime;
  374.     UnsignedFixed                     scEndTime;
  375.     UnsignedFixed                     scCurrentTime;
  376.     Boolean                         scChannelBusy;
  377.     Boolean                         scChannelDisposed;
  378.     Boolean                         scChannelPaused;
  379.     Boolean                         scUnused;
  380.     unsigned long                     scChannelAttributes;
  381.     long                             scCPULoad;
  382. };
  383. typedef struct SCStatus SCStatus;
  384.  
  385. typedef SCStatus *SCStatusPtr;
  386. struct AudioSelection {
  387.     long                             unitType;
  388.     UnsignedFixed                     selStart;
  389.     UnsignedFixed                     selEnd;
  390. };
  391. typedef struct AudioSelection AudioSelection;
  392.  
  393. typedef pascal void (*FilePlayCompletionProcPtr)(SndChannelPtr chan);
  394.  
  395. #if GENERATINGCFM
  396. typedef UniversalProcPtr FilePlayCompletionUPP;
  397. #else
  398. typedef FilePlayCompletionProcPtr FilePlayCompletionUPP;
  399. #endif
  400.  
  401. enum {
  402.     uppFilePlayCompletionProcInfo = kPascalStackBased
  403.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SndChannelPtr)))
  404. };
  405.  
  406. #if GENERATINGCFM
  407. #define NewFilePlayCompletionProc(userRoutine)        \
  408.         (FilePlayCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFilePlayCompletionProcInfo, GetCurrentArchitecture())
  409. #else
  410. #define NewFilePlayCompletionProc(userRoutine)        \
  411.         ((FilePlayCompletionUPP) (userRoutine))
  412. #endif
  413.  
  414. #if GENERATINGCFM
  415. #define CallFilePlayCompletionProc(userRoutine, chan)        \
  416.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFilePlayCompletionProcInfo, (chan))
  417. #else
  418. #define CallFilePlayCompletionProc(userRoutine, chan)        \
  419.         (*(userRoutine))((chan))
  420. #endif
  421. typedef AudioSelection *AudioSelectionPtr;
  422. struct SndDoubleBuffer {
  423.     long                             dbNumFrames;
  424.     long                             dbFlags;
  425.     long                             dbUserInfo[2];
  426.     SInt8                             dbSoundData[1];
  427. };
  428. typedef struct SndDoubleBuffer SndDoubleBuffer;
  429.  
  430. typedef SndDoubleBuffer *SndDoubleBufferPtr;
  431. typedef pascal void (*SndDoubleBackProcPtr)(SndChannelPtr channel, SndDoubleBufferPtr doubleBufferPtr);
  432.  
  433. #if GENERATINGCFM
  434. typedef UniversalProcPtr SndDoubleBackUPP;
  435. #else
  436. typedef SndDoubleBackProcPtr SndDoubleBackUPP;
  437. #endif
  438.  
  439. enum {
  440.     uppSndDoubleBackProcInfo = kPascalStackBased
  441.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SndChannelPtr)))
  442.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SndDoubleBufferPtr)))
  443. };
  444.  
  445. #if GENERATINGCFM
  446. #define NewSndDoubleBackProc(userRoutine)        \
  447.         (SndDoubleBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSndDoubleBackProcInfo, GetCurrentArchitecture())
  448. #else
  449. #define NewSndDoubleBackProc(userRoutine)        \
  450.         ((SndDoubleBackUPP) (userRoutine))
  451. #endif
  452.  
  453. #if GENERATINGCFM
  454. #define CallSndDoubleBackProc(userRoutine, channel, doubleBufferPtr)        \
  455.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSndDoubleBackProcInfo, (channel), (doubleBufferPtr))
  456. #else
  457. #define CallSndDoubleBackProc(userRoutine, channel, doubleBufferPtr)        \
  458.         (*(userRoutine))((channel), (doubleBufferPtr))
  459. #endif
  460. struct SndDoubleBufferHeader {
  461.     short                             dbhNumChannels;
  462.     short                             dbhSampleSize;
  463.     short                             dbhCompressionID;
  464.     short                             dbhPacketSize;
  465.     UnsignedFixed                     dbhSampleRate;
  466.     SndDoubleBufferPtr                 dbhBufferPtr[2];
  467.     SndDoubleBackUPP                 dbhDoubleBack;
  468. };
  469. typedef struct SndDoubleBufferHeader SndDoubleBufferHeader;
  470.  
  471. typedef SndDoubleBufferHeader *SndDoubleBufferHeaderPtr;
  472. struct SndDoubleBufferHeader2 {
  473.     short                             dbhNumChannels;
  474.     short                             dbhSampleSize;
  475.     short                             dbhCompressionID;
  476.     short                             dbhPacketSize;
  477.     UnsignedFixed                     dbhSampleRate;
  478.     SndDoubleBufferPtr                 dbhBufferPtr[2];
  479.     SndDoubleBackUPP                 dbhDoubleBack;
  480.     OSType                             dbhFormat;
  481. };
  482. typedef struct SndDoubleBufferHeader2 SndDoubleBufferHeader2;
  483.  
  484. typedef SndDoubleBufferHeader2 *SndDoubleBufferHeader2Ptr;
  485. struct SoundInfoList {
  486.     short                             count;
  487.     Handle                             infoHandle;
  488. };
  489. typedef struct SoundInfoList SoundInfoList;
  490.  
  491. typedef SoundInfoList *SoundInfoListPtr;
  492. struct SoundComponentData {
  493.     long                             flags;
  494.     OSType                             format;
  495.     short                             numChannels;
  496.     short                             sampleSize;
  497.     UnsignedFixed                     sampleRate;
  498.     long                             sampleCount;
  499.     Byte *                            buffer;
  500.     long                             reserved;
  501. };
  502. typedef struct SoundComponentData SoundComponentData;
  503.  
  504. typedef SoundComponentData *SoundComponentDataPtr;
  505. struct CompressionInfo {
  506.     long                             recordSize;
  507.     OSType                             format;
  508.     short                             compressionID;
  509.     unsigned short                     samplesPerPacket;
  510.     unsigned short                     bytesPerPacket;
  511.     unsigned short                     bytesPerFrame;
  512.     unsigned short                     bytesPerSample;
  513.     unsigned short                     futureUse1;
  514. };
  515. typedef struct CompressionInfo CompressionInfo;
  516.  
  517. typedef CompressionInfo *CompressionInfoPtr;
  518. typedef CompressionInfoPtr *CompressionInfoHandle;
  519. /*private thing to use as a reference to a Sound Converter*/
  520. typedef struct OpaqueSoundConverter* SoundConverter;
  521. #if FOR_SYSTEM7_ONLY
  522. /*
  523.  These two routines for Get/SetSoundVol should no longer be used.
  524.  They were for old Apple Sound Chip machines, and do not support the DSP or PowerMacs.
  525.  Use Get/SetDefaultOutputVolume instead, if you must change the user's machine.
  526. */
  527. #if OLDROUTINENAMES && !GENERATINGCFM
  528. extern pascal void SetSoundVol(short level);
  529.  
  530.  
  531. #if GENERATING68K && !GENERATINGCFM
  532. #pragma parameter GetSoundVol(__A0)
  533. #endif
  534. extern pascal void GetSoundVol(short *level)
  535.  THREEWORDINLINE(0x4218, 0x10B8, 0x0260);
  536.  
  537. #endif
  538. #endif
  539.  
  540.  
  541. extern pascal void SysBeep(short duration)
  542.  ONEWORDINLINE(0xA9C8);
  543.  
  544. extern pascal OSErr SndDoCommand(SndChannelPtr chan, const SndCommand *cmd, Boolean noWait)
  545.  ONEWORDINLINE(0xA803);
  546.  
  547. extern pascal OSErr SndDoImmediate(SndChannelPtr chan, const SndCommand *cmd)
  548.  ONEWORDINLINE(0xA804);
  549.  
  550. extern pascal OSErr SndNewChannel(SndChannelPtr *chan, short synth, long init, SndCallBackUPP userRoutine)
  551.  ONEWORDINLINE(0xA807);
  552.  
  553. extern pascal OSErr SndDisposeChannel(SndChannelPtr chan, Boolean quietNow)
  554.  ONEWORDINLINE(0xA801);
  555.  
  556. extern pascal OSErr SndPlay(SndChannelPtr chan, SndListHandle sndHandle, Boolean async)
  557.  ONEWORDINLINE(0xA805);
  558.  
  559. #if OLDROUTINENAMES
  560. extern pascal OSErr SndAddModifier(SndChannelPtr chan, Ptr modifier, short id, long init)
  561.  ONEWORDINLINE(0xA802);
  562.  
  563. #endif
  564. extern pascal OSErr SndControl(short id, SndCommand *cmd)
  565.  ONEWORDINLINE(0xA806);
  566.  
  567.  
  568.  
  569. /* Sound Manager 2.0 and later, uses _SoundDispatch */
  570. extern pascal NumVersion SndSoundManagerVersion(void )
  571.  FOURWORDINLINE(0x203C, 0x000C, 0x0008, 0xA800);
  572.  
  573. extern pascal OSErr SndStartFilePlay(SndChannelPtr chan, short fRefNum, short resNum, long bufferSize, void *theBuffer, AudioSelectionPtr theSelection, FilePlayCompletionUPP theCompletion, Boolean async)
  574.  FOURWORDINLINE(0x203C, 0x0D00, 0x0008, 0xA800);
  575.  
  576. extern pascal OSErr SndPauseFilePlay(SndChannelPtr chan)
  577.  FOURWORDINLINE(0x203C, 0x0204, 0x0008, 0xA800);
  578.  
  579. extern pascal OSErr SndStopFilePlay(SndChannelPtr chan, Boolean quietNow)
  580.  FOURWORDINLINE(0x203C, 0x0308, 0x0008, 0xA800);
  581.  
  582. extern pascal OSErr SndChannelStatus(SndChannelPtr chan, short theLength, SCStatusPtr theStatus)
  583.  FOURWORDINLINE(0x203C, 0x0510, 0x0008, 0xA800);
  584.  
  585. extern pascal OSErr SndManagerStatus(short theLength, SMStatusPtr theStatus)
  586.  FOURWORDINLINE(0x203C, 0x0314, 0x0008, 0xA800);
  587.  
  588. extern pascal void SndGetSysBeepState(short *sysBeepState)
  589.  FOURWORDINLINE(0x203C, 0x0218, 0x0008, 0xA800);
  590.  
  591. extern pascal OSErr SndSetSysBeepState(short sysBeepState)
  592.  FOURWORDINLINE(0x203C, 0x011C, 0x0008, 0xA800);
  593.  
  594. extern pascal OSErr SndPlayDoubleBuffer(SndChannelPtr chan, SndDoubleBufferHeaderPtr theParams)
  595.  FOURWORDINLINE(0x203C, 0x0420, 0x0008, 0xA800);
  596.  
  597.  
  598.  
  599. /* MACE compression routines */
  600. extern pascal NumVersion MACEVersion(void )
  601.  FOURWORDINLINE(0x203C, 0x0000, 0x0010, 0xA800);
  602.  
  603. extern pascal void Comp3to1(const void *inBuffer, void *outBuffer, unsigned long cnt, StateBlockPtr inState, StateBlockPtr outState, unsigned long numChannels, unsigned long whichChannel)
  604.  FOURWORDINLINE(0x203C, 0x0004, 0x0010, 0xA800);
  605.  
  606. extern pascal void Exp1to3(const void *inBuffer, void *outBuffer, unsigned long cnt, StateBlockPtr inState, StateBlockPtr outState, unsigned long numChannels, unsigned long whichChannel)
  607.  FOURWORDINLINE(0x203C, 0x0008, 0x0010, 0xA800);
  608.  
  609. extern pascal void Comp6to1(const void *inBuffer, void *outBuffer, unsigned long cnt, StateBlockPtr inState, StateBlockPtr outState, unsigned long numChannels, unsigned long whichChannel)
  610.  FOURWORDINLINE(0x203C, 0x000C, 0x0010, 0xA800);
  611.  
  612. extern pascal void Exp1to6(const void *inBuffer, void *outBuffer, unsigned long cnt, StateBlockPtr inState, StateBlockPtr outState, unsigned long numChannels, unsigned long whichChannel)
  613.  FOURWORDINLINE(0x203C, 0x0010, 0x0010, 0xA800);
  614.  
  615.  
  616.  
  617. /* Sound Manager 3.0 and later calls */
  618. extern pascal OSErr GetSysBeepVolume(long *level)
  619.  FOURWORDINLINE(0x203C, 0x0224, 0x0018, 0xA800);
  620.  
  621. extern pascal OSErr SetSysBeepVolume(long level)
  622.  FOURWORDINLINE(0x203C, 0x0228, 0x0018, 0xA800);
  623.  
  624. extern pascal OSErr GetDefaultOutputVolume(long *level)
  625.  FOURWORDINLINE(0x203C, 0x022C, 0x0018, 0xA800);
  626.  
  627. extern pascal OSErr SetDefaultOutputVolume(long level)
  628.  FOURWORDINLINE(0x203C, 0x0230, 0x0018, 0xA800);
  629.  
  630. extern pascal OSErr GetSoundHeaderOffset(SndListHandle sndHandle, long *offset)
  631.  FOURWORDINLINE(0x203C, 0x0404, 0x0018, 0xA800);
  632.  
  633. extern pascal UnsignedFixed UnsignedFixedMulDiv(UnsignedFixed value, UnsignedFixed multiplier, UnsignedFixed divisor)
  634.  FOURWORDINLINE(0x203C, 0x060C, 0x0018, 0xA800);
  635.  
  636. extern pascal OSErr GetCompressionInfo(short compressionID, OSType format, short numChannels, short sampleSize, CompressionInfoPtr cp)
  637.  FOURWORDINLINE(0x203C, 0x0710, 0x0018, 0xA800);
  638.  
  639. extern pascal OSErr SetSoundPreference(OSType theType, Str255 name, Handle settings)
  640.  FOURWORDINLINE(0x203C, 0x0634, 0x0018, 0xA800);
  641.  
  642. extern pascal OSErr GetSoundPreference(OSType theType, Str255 name, Handle settings)
  643.  FOURWORDINLINE(0x203C, 0x0638, 0x0018, 0xA800);
  644.  
  645.  
  646.  
  647. /* Sound Manager 3.1 and later calls */
  648. extern pascal OSErr SndGetInfo(SndChannelPtr chan, OSType selector, void *infoPtr)
  649.  FOURWORDINLINE(0x203C, 0x063C, 0x0018, 0xA800);
  650.  
  651. extern pascal OSErr SndSetInfo(SndChannelPtr chan, OSType selector, const void *infoPtr)
  652.  FOURWORDINLINE(0x203C, 0x0640, 0x0018, 0xA800);
  653.  
  654. extern pascal OSErr GetSoundOutputInfo(Component outputDevice, OSType selector, void *infoPtr)
  655.  FOURWORDINLINE(0x203C, 0x0644, 0x0018, 0xA800);
  656.  
  657. extern pascal OSErr SetSoundOutputInfo(Component outputDevice, OSType selector, const void *infoPtr)
  658.  FOURWORDINLINE(0x203C, 0x0648, 0x0018, 0xA800);
  659.  
  660.  
  661.  
  662. /* Sound Manager 3.2 and later calls */
  663. extern pascal OSErr GetCompressionName(OSType compressionType, Str255 compressionName)
  664.  FOURWORDINLINE(0x203C, 0x044C, 0x0018, 0xA800);
  665.  
  666. extern pascal OSErr SoundConverterOpen(const SoundComponentData *inputFormat, const SoundComponentData *outputFormat, SoundConverter *sc)
  667.  FOURWORDINLINE(0x203C, 0x0650, 0x0018, 0xA800);
  668.  
  669. extern pascal OSErr SoundConverterClose(SoundConverter sc)
  670.  FOURWORDINLINE(0x203C, 0x0254, 0x0018, 0xA800);
  671.  
  672. extern pascal OSErr SoundConverterGetBufferSizes(SoundConverter sc, unsigned long inputBytesTarget, unsigned long *inputFrames, unsigned long *inputBytes, unsigned long *outputBytes)
  673.  FOURWORDINLINE(0x203C, 0x0A58, 0x0018, 0xA800);
  674.  
  675. extern pascal OSErr SoundConverterBeginConversion(SoundConverter sc)
  676.  FOURWORDINLINE(0x203C, 0x025C, 0x0018, 0xA800);
  677.  
  678. extern pascal OSErr SoundConverterConvertBuffer(SoundConverter sc, const void *inputPtr, unsigned long inputFrames, void *outputPtr, unsigned long *outputFrames, unsigned long *outputBytes)
  679.  FOURWORDINLINE(0x203C, 0x0C60, 0x0018, 0xA800);
  680.  
  681. extern pascal OSErr SoundConverterEndConversion(SoundConverter sc, void *outputPtr, unsigned long *outputFrames, unsigned long *outputBytes)
  682.  FOURWORDINLINE(0x203C, 0x0864, 0x0018, 0xA800);
  683.  
  684.  
  685. enum {
  686.     uppSndCallBackProcInfo = kPascalStackBased
  687.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SndChannelPtr)))
  688.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SndCommand *)))
  689. };
  690.  
  691. #if GENERATINGCFM
  692. #define NewSndCallBackProc(userRoutine)        \
  693.         (SndCallBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSndCallBackProcInfo, GetCurrentArchitecture())
  694. #else
  695. #define NewSndCallBackProc(userRoutine)        \
  696.         ((SndCallBackUPP) (userRoutine))
  697. #endif
  698.  
  699. #if GENERATINGCFM
  700. #define CallSndCallBackProc(userRoutine, chan, cmd)        \
  701.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSndCallBackProcInfo, (chan), (cmd))
  702. #else
  703. #define CallSndCallBackProc(userRoutine, chan, cmd)        \
  704.         (*(userRoutine))((chan), (cmd))
  705. #endif
  706. #endif
  707.  
  708. #if PRAGMA_ALIGN_SUPPORTED
  709. #pragma options align=reset
  710. #endif
  711.  
  712. #if PRAGMA_IMPORT_SUPPORTED
  713. #pragma import off
  714. #endif
  715.  
  716. #ifdef __cplusplus
  717. }
  718. #endif
  719.  
  720. #endif /* __SOUND__ */
  721.  
  722.